home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 January: Mac OS SDK / Dev.CD Jan 99 SDK1.toast / Development Kits / Interfaces&Libraries / Universal / Interfaces / PInterfaces / SpeechSynthesis.p < prev    next >
Encoding:
Text File  |  1998-08-17  |  12.8 KB  |  436 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        SpeechSynthesis.p
  3.  
  4.      Contains:    Speech Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Release:    Universal Interfaces 3.2
  8.  
  9.      Copyright:    © 1989-1998 by Apple Computer, Inc., all rights reserved.
  10.  
  11.      Bugs?:        For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. }
  17. {$IFC UNDEFINED UsingIncludes}
  18. {$SETC UsingIncludes := 0}
  19. {$ENDC}
  20.  
  21. {$IFC NOT UsingIncludes}
  22.  UNIT SpeechSynthesis;
  23.  INTERFACE
  24. {$ENDC}
  25.  
  26. {$IFC UNDEFINED __SPEECHSYNTHESIS__}
  27. {$SETC __SPEECHSYNTHESIS__ := 1}
  28.  
  29. {$I+}
  30. {$SETC SpeechSynthesisIncludes := UsingIncludes}
  31. {$SETC UsingIncludes := 1}
  32.  
  33. {$IFC UNDEFINED __MACTYPES__}
  34. {$I MacTypes.p}
  35. {$ENDC}
  36. {$IFC UNDEFINED __MIXEDMODE__}
  37. {$I MixedMode.p}
  38. {$ENDC}
  39. {$IFC UNDEFINED __FILES__}
  40. {$I Files.p}
  41. {$ENDC}
  42.  
  43.  
  44. {$PUSH}
  45. {$ALIGN MAC68K}
  46. {$LibExport+}
  47.  
  48.  
  49. CONST
  50.     kTextToSpeechSynthType        = 'ttsc';
  51.     kTextToSpeechVoiceType        = 'ttvd';
  52.     kTextToSpeechVoiceFileType    = 'ttvf';
  53.     kTextToSpeechVoiceBundleType = 'ttvb';
  54.  
  55.     kNoEndingProsody            = 1;
  56.     kNoSpeechInterrupt            = 2;
  57.     kPreflightThenPause            = 4;
  58.  
  59.     kImmediate                    = 0;
  60.     kEndOfWord                    = 1;
  61.     kEndOfSentence                = 2;
  62.  
  63.  
  64. {------------------------------------------}
  65. { GetSpeechInfo & SetSpeechInfo selectors    }
  66. {------------------------------------------}
  67.     soStatus                    = 'stat';
  68.     soErrors                    = 'erro';
  69.     soInputMode                    = 'inpt';
  70.     soCharacterMode                = 'char';
  71.     soNumberMode                = 'nmbr';
  72.     soRate                        = 'rate';
  73.     soPitchBase                    = 'pbas';
  74.     soPitchMod                    = 'pmod';
  75.     soVolume                    = 'volm';
  76.     soSynthType                    = 'vers';
  77.     soRecentSync                = 'sync';
  78.     soPhonemeSymbols            = 'phsy';
  79.     soCurrentVoice                = 'cvox';
  80.     soCommandDelimiter            = 'dlim';
  81.     soReset                        = 'rset';
  82.     soCurrentA5                    = 'myA5';
  83.     soRefCon                    = 'refc';
  84.     soTextDoneCallBack            = 'tdcb';                        {  use with SpeechTextDoneProcPtr }
  85.     soSpeechDoneCallBack        = 'sdcb';                        {  use with SpeechDoneProcPtr }
  86.     soSyncCallBack                = 'sycb';                        {  use with SpeechSyncProcPtr }
  87.     soErrorCallBack                = 'ercb';                        {  use with SpeechErrorProcPtr }
  88.     soPhonemeCallBack            = 'phcb';                        {  use with SpeechPhonemeProcPtr }
  89.     soWordCallBack                = 'wdcb';
  90.     soSynthExtension            = 'xtnd';
  91.     soSoundOutput                = 'sndo';
  92.  
  93.  
  94. {------------------------------------------}
  95. { Speaking Mode Constants                     }
  96. {------------------------------------------}
  97.     modeText                    = 'TEXT';                        {  input mode constants                      }
  98.     modePhonemes                = 'PHON';
  99.     modeNormal                    = 'NORM';                        {  character mode and number mode constants  }
  100.     modeLiteral                    = 'LTRL';
  101.  
  102.  
  103.     soVoiceDescription            = 'info';
  104.     soVoiceFile                    = 'fref';
  105.  
  106.  
  107.  
  108. TYPE
  109.     SpeechChannel = ^LONGINT;
  110.  
  111.     VoiceSpecPtr = ^VoiceSpec;
  112.     VoiceSpec = RECORD
  113.         creator:                OSType;
  114.         id:                        OSType;
  115.     END;
  116.  
  117.  
  118.  
  119. CONST
  120.     kNeuter                        = 0;
  121.     kMale                        = 1;
  122.     kFemale                        = 2;
  123.  
  124.  
  125.  
  126.  
  127.  
  128. TYPE
  129.     VoiceDescriptionPtr = ^VoiceDescription;
  130.     VoiceDescription = RECORD
  131.         length:                    LONGINT;
  132.         voice:                    VoiceSpec;
  133.         version:                LONGINT;
  134.         name:                    Str63;
  135.         comment:                Str255;
  136.         gender:                    INTEGER;
  137.         age:                    INTEGER;
  138.         script:                    INTEGER;
  139.         language:                INTEGER;
  140.         region:                    INTEGER;
  141.         reserved:                ARRAY [0..3] OF LONGINT;
  142.     END;
  143.  
  144.  
  145.  
  146.     VoiceFileInfoPtr = ^VoiceFileInfo;
  147.     VoiceFileInfo = RECORD
  148.         fileSpec:                FSSpec;
  149.         resID:                    INTEGER;
  150.     END;
  151.  
  152.     SpeechStatusInfoPtr = ^SpeechStatusInfo;
  153.     SpeechStatusInfo = RECORD
  154.         outputBusy:                BOOLEAN;
  155.         outputPaused:            BOOLEAN;
  156.         inputBytesLeft:            LONGINT;
  157.         phonemeCode:            INTEGER;
  158.     END;
  159.  
  160.  
  161.  
  162.     SpeechErrorInfoPtr = ^SpeechErrorInfo;
  163.     SpeechErrorInfo = RECORD
  164.         count:                    INTEGER;
  165.         oldest:                    OSErr;
  166.         oldPos:                    LONGINT;
  167.         newest:                    OSErr;
  168.         newPos:                    LONGINT;
  169.     END;
  170.  
  171.  
  172.  
  173.     SpeechVersionInfoPtr = ^SpeechVersionInfo;
  174.     SpeechVersionInfo = RECORD
  175.         synthType:                OSType;
  176.         synthSubType:            OSType;
  177.         synthManufacturer:        OSType;
  178.         synthFlags:                LONGINT;
  179.         synthVersion:            NumVersion;
  180.     END;
  181.  
  182.  
  183.  
  184.     PhonemeInfoPtr = ^PhonemeInfo;
  185.     PhonemeInfo = RECORD
  186.         opcode:                    INTEGER;
  187.         phStr:                    Str15;
  188.         exampleStr:                Str31;
  189.         hiliteStart:            INTEGER;
  190.         hiliteEnd:                INTEGER;
  191.     END;
  192.  
  193.  
  194.     PhonemeDescriptorPtr = ^PhonemeDescriptor;
  195.     PhonemeDescriptor = RECORD
  196.         phonemeCount:            INTEGER;
  197.         thePhonemes:            ARRAY [0..0] OF PhonemeInfo;
  198.     END;
  199.  
  200.     SpeechXtndDataPtr = ^SpeechXtndData;
  201.     SpeechXtndData = PACKED RECORD
  202.         synthCreator:            OSType;
  203.         synthData:                PACKED ARRAY [0..1] OF Byte;
  204.     END;
  205.  
  206.  
  207.     DelimiterInfoPtr = ^DelimiterInfo;
  208.     DelimiterInfo = PACKED RECORD
  209.         startDelimiter:            PACKED ARRAY [0..1] OF Byte;
  210.         endDelimiter:            PACKED ARRAY [0..1] OF Byte;
  211.     END;
  212.  
  213.  
  214. {$IFC TYPED_FUNCTION_POINTERS}
  215.     SpeechTextDoneProcPtr = PROCEDURE(chan: SpeechChannel; refCon: LONGINT; VAR nextBuf: UNIV Ptr; VAR byteLen: UInt32; VAR controlFlags: LONGINT);
  216. {$ELSEC}
  217.     SpeechTextDoneProcPtr = ProcPtr;
  218. {$ENDC}
  219.  
  220. {$IFC TYPED_FUNCTION_POINTERS}
  221.     SpeechDoneProcPtr = PROCEDURE(chan: SpeechChannel; refCon: LONGINT);
  222. {$ELSEC}
  223.     SpeechDoneProcPtr = ProcPtr;
  224. {$ENDC}
  225.  
  226. {$IFC TYPED_FUNCTION_POINTERS}
  227.     SpeechSyncProcPtr = PROCEDURE(chan: SpeechChannel; refCon: LONGINT; syncMessage: OSType);
  228. {$ELSEC}
  229.     SpeechSyncProcPtr = ProcPtr;
  230. {$ENDC}
  231.  
  232. {$IFC TYPED_FUNCTION_POINTERS}
  233.     SpeechErrorProcPtr = PROCEDURE(chan: SpeechChannel; refCon: LONGINT; theError: OSErr; bytePos: LONGINT);
  234. {$ELSEC}
  235.     SpeechErrorProcPtr = ProcPtr;
  236. {$ENDC}
  237.  
  238. {$IFC TYPED_FUNCTION_POINTERS}
  239.     SpeechPhonemeProcPtr = PROCEDURE(chan: SpeechChannel; refCon: LONGINT; phonemeOpcode: INTEGER);
  240. {$ELSEC}
  241.     SpeechPhonemeProcPtr = ProcPtr;
  242. {$ENDC}
  243.  
  244. {$IFC TYPED_FUNCTION_POINTERS}
  245.     SpeechWordProcPtr = PROCEDURE(chan: SpeechChannel; refCon: LONGINT; wordPos: UInt32; wordLen: UInt16);
  246. {$ELSEC}
  247.     SpeechWordProcPtr = ProcPtr;
  248. {$ENDC}
  249.  
  250.     SpeechTextDoneUPP = UniversalProcPtr;
  251.     SpeechDoneUPP = UniversalProcPtr;
  252.     SpeechSyncUPP = UniversalProcPtr;
  253.     SpeechErrorUPP = UniversalProcPtr;
  254.     SpeechPhonemeUPP = UniversalProcPtr;
  255.     SpeechWordUPP = UniversalProcPtr;
  256.  
  257. CONST
  258.     uppSpeechTextDoneProcInfo = $0000FFC0;
  259.     uppSpeechDoneProcInfo = $000003C0;
  260.     uppSpeechSyncProcInfo = $00000FC0;
  261.     uppSpeechErrorProcInfo = $00003BC0;
  262.     uppSpeechPhonemeProcInfo = $00000BC0;
  263.     uppSpeechWordProcInfo = $00002FC0;
  264.  
  265. FUNCTION NewSpeechTextDoneProc(userRoutine: SpeechTextDoneProcPtr): SpeechTextDoneUPP;
  266.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  267.     INLINE $2E9F;
  268.     {$ENDC}
  269.  
  270. FUNCTION NewSpeechDoneProc(userRoutine: SpeechDoneProcPtr): SpeechDoneUPP;
  271.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  272.     INLINE $2E9F;
  273.     {$ENDC}
  274.  
  275. FUNCTION NewSpeechSyncProc(userRoutine: SpeechSyncProcPtr): SpeechSyncUPP;
  276.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  277.     INLINE $2E9F;
  278.     {$ENDC}
  279.  
  280. FUNCTION NewSpeechErrorProc(userRoutine: SpeechErrorProcPtr): SpeechErrorUPP;
  281.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  282.     INLINE $2E9F;
  283.     {$ENDC}
  284.  
  285. FUNCTION NewSpeechPhonemeProc(userRoutine: SpeechPhonemeProcPtr): SpeechPhonemeUPP;
  286.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  287.     INLINE $2E9F;
  288.     {$ENDC}
  289.  
  290. FUNCTION NewSpeechWordProc(userRoutine: SpeechWordProcPtr): SpeechWordUPP;
  291.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  292.     INLINE $2E9F;
  293.     {$ENDC}
  294.  
  295. PROCEDURE CallSpeechTextDoneProc(chan: SpeechChannel; refCon: LONGINT; VAR nextBuf: UNIV Ptr; VAR byteLen: UInt32; VAR controlFlags: LONGINT; userRoutine: SpeechTextDoneUPP);
  296.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  297.     INLINE $205F, $4E90;
  298.     {$ENDC}
  299.  
  300. PROCEDURE CallSpeechDoneProc(chan: SpeechChannel; refCon: LONGINT; userRoutine: SpeechDoneUPP);
  301.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  302.     INLINE $205F, $4E90;
  303.     {$ENDC}
  304.  
  305. PROCEDURE CallSpeechSyncProc(chan: SpeechChannel; refCon: LONGINT; syncMessage: OSType; userRoutine: SpeechSyncUPP);
  306.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  307.     INLINE $205F, $4E90;
  308.     {$ENDC}
  309.  
  310. PROCEDURE CallSpeechErrorProc(chan: SpeechChannel; refCon: LONGINT; theError: OSErr; bytePos: LONGINT; userRoutine: SpeechErrorUPP);
  311.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  312.     INLINE $205F, $4E90;
  313.     {$ENDC}
  314.  
  315. PROCEDURE CallSpeechPhonemeProc(chan: SpeechChannel; refCon: LONGINT; phonemeOpcode: INTEGER; userRoutine: SpeechPhonemeUPP);
  316.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  317.     INLINE $205F, $4E90;
  318.     {$ENDC}
  319.  
  320. PROCEDURE CallSpeechWordProc(chan: SpeechChannel; refCon: LONGINT; wordPos: UInt32; wordLen: UInt16; userRoutine: SpeechWordUPP);
  321.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  322.     INLINE $205F, $4E90;
  323.     {$ENDC}
  324. FUNCTION SpeechManagerVersion: NumVersion;
  325.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  326.     INLINE $203C, $0000, $000C, $A800;
  327.     {$ENDC}
  328. FUNCTION MakeVoiceSpec(creator: OSType; id: OSType; VAR voice: VoiceSpec): OSErr;
  329.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  330.     INLINE $203C, $0604, $000C, $A800;
  331.     {$ENDC}
  332. FUNCTION CountVoices(VAR numVoices: INTEGER): OSErr;
  333.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  334.     INLINE $203C, $0108, $000C, $A800;
  335.     {$ENDC}
  336. FUNCTION GetIndVoice(index: INTEGER; VAR voice: VoiceSpec): OSErr;
  337.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  338.     INLINE $203C, $030C, $000C, $A800;
  339.     {$ENDC}
  340. FUNCTION GetVoiceDescription({CONST}VAR voice: VoiceSpec; VAR info: VoiceDescription; infoLength: LONGINT): OSErr;
  341.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  342.     INLINE $203C, $0610, $000C, $A800;
  343.     {$ENDC}
  344. FUNCTION GetVoiceInfo({CONST}VAR voice: VoiceSpec; selector: OSType; voiceInfo: UNIV Ptr): OSErr;
  345.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  346.     INLINE $203C, $0614, $000C, $A800;
  347.     {$ENDC}
  348. FUNCTION NewSpeechChannel(voice: VoiceSpecPtr; VAR chan: SpeechChannel): OSErr;
  349.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  350.     INLINE $203C, $0418, $000C, $A800;
  351.     {$ENDC}
  352. FUNCTION DisposeSpeechChannel(chan: SpeechChannel): OSErr;
  353.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  354.     INLINE $203C, $021C, $000C, $A800;
  355.     {$ENDC}
  356. FUNCTION SpeakString(textToBeSpoken: Str255): OSErr;
  357.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  358.     INLINE $203C, $0220, $000C, $A800;
  359.     {$ENDC}
  360. FUNCTION SpeakText(chan: SpeechChannel; textBuf: UNIV Ptr; textBytes: UInt32): OSErr;
  361.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  362.     INLINE $203C, $0624, $000C, $A800;
  363.     {$ENDC}
  364. FUNCTION SpeakBuffer(chan: SpeechChannel; textBuf: UNIV Ptr; textBytes: UInt32; controlFlags: LONGINT): OSErr;
  365.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  366.     INLINE $203C, $0828, $000C, $A800;
  367.     {$ENDC}
  368. FUNCTION StopSpeech(chan: SpeechChannel): OSErr;
  369.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  370.     INLINE $203C, $022C, $000C, $A800;
  371.     {$ENDC}
  372. FUNCTION StopSpeechAt(chan: SpeechChannel; whereToStop: LONGINT): OSErr;
  373.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  374.     INLINE $203C, $0430, $000C, $A800;
  375.     {$ENDC}
  376. FUNCTION PauseSpeechAt(chan: SpeechChannel; whereToPause: LONGINT): OSErr;
  377.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  378.     INLINE $203C, $0434, $000C, $A800;
  379.     {$ENDC}
  380. FUNCTION ContinueSpeech(chan: SpeechChannel): OSErr;
  381.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  382.     INLINE $203C, $0238, $000C, $A800;
  383.     {$ENDC}
  384. FUNCTION SpeechBusy: INTEGER;
  385.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  386.     INLINE $203C, $003C, $000C, $A800;
  387.     {$ENDC}
  388. FUNCTION SpeechBusySystemWide: INTEGER;
  389.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  390.     INLINE $203C, $0040, $000C, $A800;
  391.     {$ENDC}
  392. FUNCTION SetSpeechRate(chan: SpeechChannel; rate: Fixed): OSErr;
  393.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  394.     INLINE $203C, $0444, $000C, $A800;
  395.     {$ENDC}
  396. FUNCTION GetSpeechRate(chan: SpeechChannel; VAR rate: Fixed): OSErr;
  397.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  398.     INLINE $203C, $0448, $000C, $A800;
  399.     {$ENDC}
  400. FUNCTION SetSpeechPitch(chan: SpeechChannel; pitch: Fixed): OSErr;
  401.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  402.     INLINE $203C, $044C, $000C, $A800;
  403.     {$ENDC}
  404. FUNCTION GetSpeechPitch(chan: SpeechChannel; VAR pitch: Fixed): OSErr;
  405.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  406.     INLINE $203C, $0450, $000C, $A800;
  407.     {$ENDC}
  408. FUNCTION SetSpeechInfo(chan: SpeechChannel; selector: OSType; speechInfo: UNIV Ptr): OSErr;
  409.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  410.     INLINE $203C, $0654, $000C, $A800;
  411.     {$ENDC}
  412. FUNCTION GetSpeechInfo(chan: SpeechChannel; selector: OSType; speechInfo: UNIV Ptr): OSErr;
  413.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  414.     INLINE $203C, $0658, $000C, $A800;
  415.     {$ENDC}
  416. FUNCTION TextToPhonemes(chan: SpeechChannel; textBuf: UNIV Ptr; textBytes: UInt32; phonemeBuf: Handle; VAR phonemeBytes: LONGINT): OSErr;
  417.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  418.     INLINE $203C, $0A5C, $000C, $A800;
  419.     {$ENDC}
  420. FUNCTION UseDictionary(chan: SpeechChannel; dictionary: Handle): OSErr;
  421.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  422.     INLINE $203C, $0460, $000C, $A800;
  423.     {$ENDC}
  424.  
  425.  
  426. {$ALIGN RESET}
  427. {$POP}
  428.  
  429. {$SETC UsingIncludes := SpeechSynthesisIncludes}
  430.  
  431. {$ENDC} {__SPEECHSYNTHESIS__}
  432.  
  433. {$IFC NOT UsingIncludes}
  434.  END.
  435. {$ENDC}
  436.